<template>
  <div id="activity-delete" class="container">
    <h1>删除活动</h1>
    <el-form ref="form" :model="form" label-position="top80px">
      <el-form-item>
        <el-input v-model="form.id" placeholder="请输入活动ID"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="danger" @click="handleDelete()">删除</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { deleteActivity } from '../api/api';

export default {
  data() {
    return {
      form: {
        id: null,
      },
    };
  },
  methods: {
    handleDelete() {
      if (this.form.id === null) {
        this.$message.warning("请输入活动ID");
      } else {
        const idString = this.form.id.toString();
        deleteActivity(idString)
          .then((response) => {
            if (response.data === "删除成功") {
              this.$message.success("删除成功");
            } else {
              this.$message.info(response.data);
            }
          })
      }
    },
  },
};
</script>

<style scoped>
#activity-delete {
  width: 500px;
  margin: 0 auto;
}

#activity-delete h1 {
  text-align: center;
  color: #333;
}

#activity-delete .el-form {
  margin-top: 20px;
}

#activity-delete .el-input {
  width: 100%;
  margin-bottom: 10px;
}

#activity-delete .el-button {
  width: 100%;
  background-color: #f44336;
  color: #fff;
}
</style>
